package assdraw.event;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import assdraw.view.DrawingCanvas;

public class ColorRadioListener implements ActionListener{

	DrawingCanvas canvas;
	
	public ColorRadioListener(DrawingCanvas canvas) {
		super();
		this.canvas = canvas;
	}

	
	public enum Colors{
		BLACK, BLUE, PINK, GREEN 
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		switch(convert(e.getActionCommand())){
		
			case BLACK:
				canvas.setCurrentColor(Color.BLACK);
				break;
			case BLUE:
				canvas.setCurrentColor(Color.BLUE);
				break;
			case GREEN:
				canvas.setCurrentColor(Color.GREEN);
				break;
			case PINK:
				canvas.setCurrentColor(Color.PINK);
				break;			
			
			default:
				
		}
		
	}

	private Colors convert(String s){
		if(s.equalsIgnoreCase("black")){
			return Colors.BLACK;
		}else if(s.equalsIgnoreCase("blue")){
			return Colors.BLUE;
		}else if(s.equalsIgnoreCase("green")){
			return Colors.GREEN;
		}else if(s.equalsIgnoreCase("pink")){
			return Colors.PINK;
		}
		return Colors.BLACK;
	}
	 
	
}
